<g:if test="${flash.messagePosition}">
  <div class="message">${flash.messagePosition}</div>
</g:if>
<g:if test="${flash.messagePositionError}">
  <div class="errors">${flash.messagePositionError}</div>
</g:if>
<table>
  <thead>
  <tr>
    <g:sortableColumn property="name" title="Name"/>
    <g:sortableColumn property="description" title="Description"/>
    <g:sortableColumn property="location" title="Location"/>
    <g:sortableColumn property="requires" title="Requires"/>
    <g:sortableColumn property="available" title="Available"/>
    <g:sortableColumn property="startDate" title="Start Date"/>
    <g:sortableColumn property="ignore" title="Action"/>
    <!--<td>" "</td>-->
  </tr>
  </thead>
  <tbody>
  <g:if test="${eventInstance?.positions?.size() == 0}">
    <tr>
      <td colspan=7>No positions are defined</td>
    </tr>
  </g:if>
  <g:each in="${eventInstance.positions}" status="i" var="positionInstance">
    <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
      <td><g:link controller="position" action="showDetails" id="${positionInstance.id}" params="[administratorId:eventInstance.administrator.id]">${fieldValue(bean: positionInstance, field: 'name')}</g:link></td>
      <td>${fieldValue(bean: positionInstance, field: 'description')}</td>
      <td>${fieldValue(bean: positionInstance, field: 'location')}</td>
      <td>${fieldValue(bean: positionInstance, field: 'requires')}</td>
      <td>${positionInstance.requires - positionInstance?.volunteers.size()}</td>
      <td>${fieldValue(bean: positionInstance, field: 'startDate')}</td>
      <g:if test="${positionInstance.requires > positionInstance?.volunteers?.size()}">
        <td><span class="button"><g:remoteLink class="delete" controller="position" action="addVolunteer" update="confirmationMessage" params="[positionId:positionInstance.id, userId:session.user.id, eventId:eventInstance.id]">Volunteer</g:remoteLink></span>
      </g:if>
      <g:else>
        <td>Filled</td>
      </g:else>
    </tr>
  </g:each>
  </tbody>
</table>
